Skip to main content

Bi-directional method type

The client must initiate the connection. Is : many calls -> many responses

Bidirectional streaming RPCs where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved.

Di-directional

rpc JustHellos(stream HelloRequest) returns (stream HelloResponse);

consuming bidirectional
public override async Task BiDirectional(IAsyncStreamReader<Request> requestStream, IServerStreamWriter<Response> responseStream, ServerCallContext context)
{
var baseMessage = "";

Response reply = new Response() { Message = baseMessage };
while (await requestStream.MoveNext())
{
var payload = requestStream.Current;


reply.Message = baseMessage + payload.ContentValue.ToString();
await responseStream.WriteAsync(reply);

}
}

Consuming